export function searchColumns() {
  return [
    {
      prop: 'name',
      placeholder: '请输入影片名称',
    },
    {
      prop: 'cooperation_platform',
      placeholder: '请输入合作平台',
    },
    {
      filterable: true,
      type: 'select',
      prop: 'category_id',
      dicData: this.movieTypeList,
      placeholder: '请选择影片分类',
    },
    {
      type: 'select',
      dicData: [
        { value: 1, label: '待上架' },
        { value: 2, label: '已上架' },
      ],
      props: {
        label: 'label',
        value: 'value',
      },
      prop: 'status',
      placeholder: '请选择影片状态',
    },
  ]
}

export function tableColumns() {
  const queryName = row => {
    return row?.map(it => it?.name)?.join(',')
  }
  return [
    {
      width: 80,
      label: '序号',
      prop: 'id',
    },
    {
      overHidden: true,
      width: 200,
      label: '影片名称',
      prop: 'name',
      align: 'left',
    },
    {
      type: 'img',
      label: '影片海报',
      prop: 'image',
      formatter: row => `${process.env.VUE_APP_CND + row?.image}`,
    },
    {
      width: 150,
      align: 'left',
      label: '影片分类',
      prop: 'category_name',
    },
    {
      label: '影片状态',
      prop: 'status',
      html: true,
      formatter: row =>
        `<span class="${row?.status === 1 ? 'text-danger' : 'text-success'}">${
          row?.status === 1 ? '待上架' : '已上架'
        }</span>`,
    },
    {
      overHidden: true,
      width: 180,
      align: 'left',
      label: '上架国家',
      prop: 'countries',
      formatter: row => queryName(row?.countries),
    },
    {
      width: 100,
      label: '影片总集数',
      prop: 'episodes',
    },
    {
      width: 100,
      align: 'right',
      label: '平均单价/集',
      prop: 'meanAmount',
      formatter: row => (row?.episodes_total_coins / 10000 / row?.episodes).toFixed(2) || '--',
    },
    {
      width: 100,
      align: 'right',
      label: '影片总价',
      prop: 'episodes_total_coins',
      formatter: row => row?.episodes_total_coins / 10000 || '--',
    },
    {
      width: 70,
      label: '语言',
      prop: 'language',
    },
    {
      overHidden: true,
      width: 200,
      align: 'left',
      label: '营销关键词',
      prop: 'keywords_name',
      formatter: row => queryName(row?.keywords_name),
    },
    {
      width: 70,
      label: '权重',
      prop: 'weight',
    },
    {
      width: 120,
      label: '平均过期时间',
      prop: 'episodes_total_valid_duration',
      formatter: row =>
        `用户购买后,${
          row?.episodes_total_valid_duration === 600 / row?.episodes
            ? '10'
            : row?.episodes_total_valid_duration / 86400 / row?.episodes
        }${row?.episodes_total_valid_duration === 600 / row?.episodes ? '分钟' : '天'}`,
    },
    {
      label: '合作平台',
      prop: 'cooperation_platform',
    },
    {
      width: 140,
      label: '最后一次编辑时间',
      prop: 'updated_at',
      formatter: row => this.$formatTime(row?.updated_at),
    },
  ]
}
